<?php
namespace app\common\tool;

class Jisongbang {
	private static $algorithm = 'AES-256-ECB';
    private static $secretKey = '8db43Aecb5249Gd706c2bb6fIrd6a7f6';
    private static $options = OPENSSL_RAW_DATA;

    /**
     * 加密方法（与Java AES/ECB/PKCS5Padding兼容）
     */
    public static function encrypt($data) {
        // 执行加密
        $encrypted = openssl_encrypt(
            $data,
            self::$algorithm,
            self::$secretKey,
            self::$options
        );
        
        // 转换为Base64编码（与Java Base64.getEncoder()一致）
        return base64_encode($encrypted);
    }

    /**
     * 解密方法（与Java AES/ECB/PKCS5Padding兼容）
     */
    public static function decrypt($encryptedData) {
        // 解码Base64
        $decoded = base64_decode($encryptedData);
        
        // 执行解密
        $decrypted = openssl_decrypt(
            $decoded,
            self::$algorithm,
            self::$secretKey,
            self::$options
        );
        
        return $decrypted;
    }

	public function get_express_info($no) {
		$data = static::encrypt($no);
		$curl = loadTool('Curl');
		$domain = '';
		if(loader()->loadAny('request', 'Jisongbang')->domain() == 'https://testxiangcunxiancang.jxoxy.com') {
			$domain = 'http://dev2.skcxcct.com:9999';
		} else {
			$domain = 'https://quickdashapi.skcxcct.com';
		}
		$result = $curl->jisongbang($domain . '/quickDash-api/wayBill/wayBillTransportInfo', $data);
		return $result;
	}
}
